Skip to content

Conversation

evanlinjin
Copy link
Contributor

  • Key spend path should take into consideration the scriptSigLen, stackLen and itemLen (for the one and only stack item).
  • Script spend path should consider control_block and script to be items on the stack.

I also restructured the function to improve readability.

@evanlinjin
Copy link
Contributor Author

This work is based on my understanding of BIP-0141 and BIP-0341. I'm not sure what is the best way to test this, any ideas will be appreciated.

LLFourn
LLFourn previously approved these changes Oct 6, 2022
Copy link
Contributor

@LLFourn LLFourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK fa2e4e2

let tree = match self.taptree() {
// key spend path:
// scriptSigLen(4) + stackLen(1) + stack[Sig]Len(1) + stack[Sig](65)
None => return Ok(4 + 1 + 1 + 65),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the 65 here is implicitly taking into account an optional sighash flag (because we're doing max I guess this strictly correct). Maybe worth doing a 64 + 1 to indicate this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LLFourn Thank you for the review.

However, at the same time, the sig+sigHash is a single stack item? Maybe a comment would be more appropriate?

@apoelstra
Copy link
Member

I think you need to update some tests:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `274`,
 right: `273`', examples/taproot.rs:123:5

for me locally.

@apoelstra
Copy link
Member

Sorry, but could you squash these commitst so the tests pass on every commit?

* Key spend path should take into consideration the scriptSigLen,
  stackLen and itemLen (for the one and only stack item).
* Script spend path should consider `control_block` and `script` to be
  items on the stack.

I also restructured the function to improve readability.
@evanlinjin evanlinjin force-pushed the fix_max_satisfaction_weight_calculations branch from edc583c to 8834b7f Compare October 6, 2022 16:10
@evanlinjin
Copy link
Contributor Author

Sorry, but could you squash these commitst so the tests pass on every commit?

@apoelstra All done :)

Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 8834b7f. Thanks for the significant code improvement.

@evanlinjin evanlinjin requested a review from LLFourn October 7, 2022 13:56
Copy link
Contributor

@LLFourn LLFourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 8834b7f

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 8834b7f

@apoelstra apoelstra merged commit 22ac742 into rust-bitcoin:master Oct 8, 2022
@apoelstra
Copy link
Member

I'd like to cut a release today. Should we revert this for now?

@evanlinjin
Copy link
Contributor Author

I'd like to cut a release today. Should we revert this for now?

@apoelstra I don't think this fix conflicts with the conversation we were having in regards to what would be the definition of "max satisfaction weight".

I think we should continue discussing whether we should merge #474 or go with #476 instead.

Let me know your thoughts on those PRs.

sanket1729 added a commit to sanket1729/elements-miniscript that referenced this pull request Oct 21, 2022
…022_10

22ac742 Merge rust-bitcoin/rust-miniscript#473: Fix `max_satisfaction_weight` calculations for taproot.
heap-coder added a commit to heap-coder/rust-miniscript that referenced this pull request Sep 27, 2025
… calculations for taproot.

8834b7f992979143e0e6e27dea9a5b79d2e34f03 Fix `max_satisfaction_weight` calculations for taproot (志宇)

Pull request description:

  * Key spend path should take into consideration the scriptSigLen, stackLen and itemLen (for the one and only stack item).
  * Script spend path should consider `control_block` and `script` to be items on the stack.

  I also restructured the function to improve readability.

ACKs for top commit:
  sanket1729:
    utACK 8834b7f992979143e0e6e27dea9a5b79d2e34f03. Thanks for the significant code improvement.
  LLFourn:
    ACK 8834b7f992979143e0e6e27dea9a5b79d2e34f03
  apoelstra:
    ACK 8834b7f992979143e0e6e27dea9a5b79d2e34f03

Tree-SHA512: e2f7c893bf9f9d13deae047b1d341fef513c8b1e4e0d4285684c5c420baabc89ae84033162534ee1dfd0c98e39bef01451a0e75e400cece37ec9218b2881a16f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants